<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商户文件下载队列列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>操作类型：</label>
                                <select name="operatorType">
                                    <option value="7">商户规则文件导入</option>
                                </select>
                            </li>

                            <li>
                                <label>状态：</label>
                                <select name="status">
                                    <option value="">请选择</option>
                                    <option value="0">生成成功</option>
                                    <option value="1">生成失败</option>
                                    <option value="2">正在生成</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label >创建日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始日期" name="params[beginAddTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束日期" name="params[endAddTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

                <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="job:task:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('job:task:edit')}]];
        var removeFlag = [[${@permission.hasPermi('job:task:remove')}]];
        var download = [[${@permission.hasPermi('job:task:download')}]];
        var prefix = ctx + "job/task";

        $(function() {
            var options = {
                url: prefix + "/allList",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "文件下载队列",
                clickToSelect:true,
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'fileName',
                    title: '文件名称',
                    formatter: function (value, row, index) {
                        return value.substr(value.lastIndexOf('/')+1,value.length)
                    },
                },
                {
                    field: 'operatorType',
                    title: '操作类型',
                    formatter: function (value, row, index) {
                        if (value == '7' ){
                            return '<span style="color: green">商户规则文件导入</span>';
                        } else {
                            return '<span style="color: #1E793F">未知</span>';
                        }
                    },
                },
                {
                    field: 'operatorContent',
                    title: '操作内容'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        if (value == '0' ){
                            return '<span style="color: green">生成成功</span>';
                        } else if(value == '1' ){
                            return '<span style="color: red">生成失败</span>';
                        } else if(value == '2' ){
                            return '<span style="color: blue">正在生成</span>';
                        } else {
                            return '<span style="color: grey">暂无</span>';
                        }
                    },
                },
                {
                    field: 'createBy',
                    title: '操作人'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status=='0') {
                            actions.push('<a class="btn btn-success btn-xs ' + download + '" href="javascript:void(0)" onclick="downloadFile(\'' + row.fileName + '\')"><i class="fa fa-download"></i>下载</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function downloadFile(fileName){
            $.modal.confirm("确定下载吗？", function() {
                window.location.href = ctx + "common/downloadLast?fileName=" + encodeURI(fileName) + "&delete=" + false;
            });
        }

    </script>
</body>
</html>